import { APILX } from '@/api/requestLx'
import { getDictModel } from '@/api/goodsManagement'

export let goodsColumns = [
  {
    title: '物品编号',
    key: 'serialNumber',
    dataIndex: 'serialNumber',
  },
  {
    title: '物品名称',
    key: 'serialName',
    dataIndex: 'serialName',
    width: '20%',
    // isrequired: true,
    // type: FormTypes.slot,
    // slotName: 'processCodeName',
  },
  {
    title: '规格',
    key: 'serialSpecifications',
    dataIndex: 'serialSpecifications',
    width: '20%',
    // isrequired: true,
    // type: FormTypes.slot,
    // slotName: 'processCodeName',
  },
  {
    title: '物品属性',
    key: 'unitName',
    dataIndex: 'serialProperties',
    width: '20%',
    // isrequired: true,
    // type: FormTypes.slot,
    // slotName: 'processCodeName',
  },
  {
    title: '单位',
    key: 'unitName',
    dataIndex: 'unitName',
    width: '20%',
    // isrequired: true,
    // type: FormTypes.slot,
    // slotName: 'processCodeName',
  },

]
export let columns = [
  {
    title: '物品编号',
    dataIndex: 'serialNumber',
    ellipsis: true,
    // fixed: 'left',
    width: 200,
    searchIndex: 'serialNumber',
    scopedSlots: {
      filterDropdown: 'searchDropdown',
      filterIcon: 'searchIcon',
      customRender: 'serialNumber',
    },
  },
  {
    title: '物品名称',
    dataIndex: 'serialName',
    ellipsis: true,
    // fixed: 'left',
    width: 180,
    searchIndex: 'serialName',
    options: [],
    scopedSlots: {
      filterDropdown: 'searchDropdown',
      filterIcon: 'searchIcon',
      customRender: 'serialName',
    },
  },
  {
    title: '规格',
    dataIndex: 'serialSpecifications',
    ellipsis: true,
    // fixed: 'left',
    width: 180,
    searchIndex: 'serialSpecifications',
    options: [],
    scopedSlots: {
      filterDropdown: 'searchDropdown',
      filterIcon: 'searchIcon',
      customRender: 'serialSpecifications',
    },
  },
  {
    title: '单位',
    dataIndex: 'unitName',
    ellipsis: true,
    // fixed: 'left',
    width: 180,
    // searchIndex: 'unitName',
    // options: [],
    scopedSlots: {
      // filterDropdown: 'selectPeople',
      // filterIcon: 'dateIcon',
      customRender: 'unitName',
    },
  },
  {
    title: '物品属性',
    dataIndex: 'serialPropertiesName',
    ellipsis: true,
    width: 180,
    searchIndex: 'serialProperties',
    options: [],
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'serialPropertiesName',
    },
  },
  {
    title: '库存数量',
    dataIndex: 'inventoryNum',
    ellipsis: true,
    // fixed: 'left',
    width: 180,
    sorter: true,
    searchIndex: 'inventoryNum',
    options: [],
    scopedSlots: {
      // filterDropdown: 'searchDropdown',
      // filterIcon: 'searchIcon',
      // customRender: 'inventoryNum',
    },
  },


  {
    title: '最小库存',
    dataIndex: 'inventoryMin',
    ellipsis: true,
    width: 180,
    searchIndex: 'inventoryMin',
    sorter: true,
    scopedSlots: {
      // filterDropdown: 'selectPeople',
      // filterIcon: 'dateIcon',
      customRender: 'inventoryMin',
    },
  },
  {
    title: '最大库存',
    dataIndex: 'inventoryMax',
    ellipsis: true,
    width: 180,
    searchIndex: 'inventoryMax',
    sorter: true,
    scopedSlots: {
      // filterDropdown: 'selectPeople',
      // filterIcon: 'dateIcon',
      customRender: 'inventoryMax',
    },
  },
  {
    title: '工艺路线',
    dataIndex: 'processRouteName',
    ellipsis: true,
    width: 180,
    searchIndex: 'processRouteName',
    scopedSlots: {
      // filterDropdown: 'selectPeople',
      // filterIcon: 'dateIcon',
      // customRender: 'processRouteName',
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    ellipsis: true,
    width: 180,
    searchIndex: 'createTime',
    sorter: true,
    scopedSlots: {
      // filterDropdown: 'datePicker',
      // filterIcon: 'dateIcon',
      // customRender: 'createTime',
    },
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
    ellipsis: true,
    width: 180,
    searchIndex: 'updateTime',
    sorter: true,
    scopedSlots: {
      // filterDropdown: 'datePicker',
      // filterIcon: 'dateIcon',
      // customRender: 'updateTime',
    },
  },
  {
    title: '创建人',
    dataIndex: 'createByName',
    ellipsis: true,
    width: 180,
    searchIndex: 'createBy',
    scopedSlots: {
      filterDropdown: 'createBy',
      filterIcon: 'dateIcon',
      customRender: 'createByName',
    },
  },
  {
    title: '更新人',
    dataIndex: 'updateByName',
    ellipsis: true,
    width: 180,
    searchIndex: 'updateBy',
    scopedSlots: {
      filterDropdown: 'updateBy',
      filterIcon: 'dateIcon',
      customRender: 'updateByName',
    },
  },

]
export let allColumn = [
  ...columns
]

export function getTypeList() {
  let parameters = { dictCode: 'SERIAL_PROPERTIES' }

  getDictModel(parameters).then((res) => {
    if (res.code == 200) {
      let goodAttribute = JSON.parse(JSON.stringify(res.result)).map((item) => {
        return {
          label: item.title,
          key: item.value,
        }
      })
      columns[4].options = goodAttribute
      allColumn[4].options = goodAttribute
    }
    // this.$store.commit('SET_CURRENT_PREFIX', '/jksaas-easyMake/easyMake')
  })
  APILX.warehouseOutboundOrderInfoEntryType().then((res) => {
    let newArrApply = res.result.map((item) => {
      return {
        label: item.itemText,
        key: item.itemValue,
      }
    })
    columns[1].options = newArrApply
    allColumn[1].options = newArrApply
  })

}
